export default {
	data() {
		return {
			// 用来装取排名信息
			rankList: [],
			rankList2: null,
			list: [{
					name: '建筑企业',
					checked: true
				},
				{
					name: '造价企业',
					checked: false
				},
				{
					name: '工程企业',
					checked: false
				},
				{
					name: '监理企业',
					checked: false
				}
			],
			current: 0,
			areaObj: null
		}
	},
	onLoad(option) {
		
		this.current = option.order
		this.areaObj = {}

		// 拿取上个页面的位置信息
		if (option.companyCity) {
			this.areaObj.companyCity = option.companyCity
		}
		if (option.companyProvince) {
			this.areaObj.companyProvince = option.companyProvince
		}
		if (!option.companyCity && !option.companyProvince) {
			let address = uni.getStorageSync('zb_setCurrentAddress')
			// this.currentAddress.companyCity=address.cityName
			if (address) {
				this.areaObj.companyProvince = address.provinceName
			}
		}

		this.enterpriseRank('jianZhu')
		this.enterpriseRank('zaoJia')
		this.enterpriseRank('sheJi')
		this.enterpriseRank('jianLi')
	},
	beforeMount() {
		//排行查询



	},

	methods: {
		changeSub(index){
		
			this.list.forEach(item=>{
				item.checked=false
			})
			this.list[index].checked=true
			
			this.rankList2 = this.rankList[index]
		},
		// 跳转至公司详情页面
		toDetailEnterprise(item) {

			// 将企业ID传值至详情页面
			uni.navigateTo({
				url: `/pagesFind/detailenterprise/detailenterprise?companyCid=${item.companyCid}`
			})
		},
		// 查询企业排名
		enterpriseRank(type) {
			// console.log("this.areaObj.companyCity", this.areaObj)
			let param = {
				qualification: type
			}
			if (this.areaObj.companyCity) {
				param.companyCity = this.areaObj.companyCity
			}
			if (this.areaObj.companyProvince) {
				param.companyProvince = this.areaObj.companyProvince
			}
			this.$app.request({
				url: this.$baseApp.api.check.findCompanyRankingList,
				data: param,
				method: 'GET',
				dataType: 'json',
				success: res => {
					// res.data.content.forEach(item=>{
					// 	if(item.companyName.length>20){
					// 		item.companyName=item.companyName.slice(0,20)+'...'
					// 	}
					// })
					// console.log("++++++排行查询+++++++", res)
					this.rankList.push(res.data.content)
				},
				complete: res => {
					this.rankList2 = this.rankList[0]
					// console.log("this.rankList2", this.rankList2)
				}
			});


		},

		sectionChange(index) {
			this.current = index;
			
			this.rankList2 = this.rankList[index]
		}
	}
}
